﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ERPStudio;
using System.Data.SqlClient;

namespace ExBug
{
    public partial class ALRezFrm : FrmRezumat
    {
        public ALRezFrm(ModuleClass mc):base(mc)
        {
            InitializeComponent();
            workConnString = mc.workConnectionString;
        }

        private void ALRezFrm_Load(object sender, EventArgs e)
        {
            if (ModuleInfo.CurrentTheme == "tribunal")
            {
                AddButton("Adauga[F8]", global::ERPStudio.Properties.Resources.adauga, AdaugaAL, ToolStripItemAlignment.Left, false);
                HandleDel += Adauga;
            }
            SqlConnection con = DeschideConexiune(workConnString);
            jurnaleTableAdapter.Connection = con;
            jurnaleTableAdapter.Fill(eSRPDataSet.Jurnale, ModuleInfo.CodUnitate);
            this.angajamentLegalDetaliuTableAdapter.Connection = con;
            this.angajamentLegalDetaliuTableAdapter.Fill(this.eSRPDataSet.AngajamentLegalDetaliu);
            this.angajamentLegalTableAdapter.Connection = con;
            this.angajamentLegalTableAdapter.Fill(this.eSRPDataSet.AngajamentLegal, ModuleInfo.CodUnitate);
            InchideConexiune(con);
        }

        private void AdaugaAL(object sender, EventArgs e)
        {
            ALFrm frm = new ALFrm(ModuleInfo);
            //frm.MdiParent = MdiParent;
            frm.AddMode = true;
            frm.ShowDialog();
            if (frm.NoRecUpdated != 0)
            {
                SqlConnection con = DeschideConexiune(workConnString);
                this.angajamentLegalDetaliuTableAdapter.Connection = con;
                this.angajamentLegalDetaliuTableAdapter.Fill(this.eSRPDataSet.AngajamentLegalDetaliu);
                this.angajamentLegalTableAdapter.Connection = con;
                this.angajamentLegalTableAdapter.Fill(this.eSRPDataSet.AngajamentLegal, ModuleInfo.CodUnitate);
                InchideConexiune(con);
            }
        }
    }
}
